package com.matrix.gui;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.TextView;
/**
 * A customized widget to represent the boxes in the main activity.
 * 
 * @author Sultan
 * Last modified: April 27th, 2011
 */
public class Box extends TextView
{

	/**
	 * instance variables.
	 */
	private Paint paint, paintText;
	RectF   inset;
	
	/**
	 * constructor
	 * @param context
	 * @param ats
	 * @param ds
	 */
	public Box(Context context, AttributeSet ats, int ds) {
		super(context, ats, ds);
		init();
	}

	/**
	 * constructor
	 * @param context
	 */
	public Box(Context context) {
		super(context);
		init();
	}

	/**
	 * constructor
	 * @param context
	 * @param attrs
	 */
	public Box(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	/**
	 * Method to initialize all the objects in this class.
	 */
	private void init()
	{
		paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		paintText = new Paint(Paint.ANTI_ALIAS_FLAG);
		paintText.setColor(Color.WHITE);
	}

	/**
	 * on Draw method. 
	 */
	@Override
	public void onDraw(Canvas canvas)
	{
		float width = getMeasuredWidth();
		float height = getMeasuredHeight();
        this.inset = new RectF(0, 0, width, height);
        if(isPressed())	
        {
        	paint.setColor(Color.BLUE);
        }
        else
        {
    		paint.setColor((Color.rgb(139,139,131)));
        }
		canvas.drawRoundRect(inset, 6, 6, paint);

		paintText.setTextSize(super.getTextSize());
		super.onDraw(canvas);
	}
}